﻿$(function(){
	loadNotificationData();
});

function loadNotificationData(){
	var prefix = "http://www.51rrkan.com/";
	var names = localStorage["newIndex"];
	if(names.length == 0) {
	    $li = $("<li>暂无视频更新~</li>");
		$("#notiContent").append($li);
	};
	console.log("names:" + names);
	var key = names.split(","); 
	for(var i = 0; i < key.length; i++){
		console.log(key[i] + ":" + localStorage[key[i]]);
		var obj = JSON.parse(localStorage[key[i]]);
		console.log("detail key: " + key[i] + "_detail");
		console.log("detail:" + localStorage[key[i] + "_detail"]);
		
		if(localStorage[key[i] + "_detail"] != null && localStorage[key[i] + "_detail"].length > 0) {
		    console.log(localStorage[key[i] + "_detail"]);
			
			var objDetail = JSON.parse(localStorage[key[i] + "_detail"]);
			$div = $('<div class="imginfo i_info" style="display: block;" align="left"></div>');
			
			$a = $('<a target="_blank" class="img_a" href="' + obj.link + '"><img width="93" height="132" alt="' + obj.name + '" src="' + objDetail.logo + '"></a>');
			
			$dl = $('<dl class="info_a"><dl>');
			$dt = $("<dt><a href='"+ obj.link + "' title='" + obj.name +"' target='_blank'>" + obj.name +"</a></dt>");
			
			$ddNote = $("<dd>" + objDetail.note + "</dd>");
			//$ddMainCharLabel = $("<dd>主演:" +  +"</dd>");
			$ddLang = $("<dd>语言：" + objDetail.lang + "</dd>");
			$ddState = $("<dd>状态：" + obj.state + "</dd>");
			$ddScore = $('<dd>评分：<font color="red">' + objDetail.score +'</font></dd>');
			
			$dl.append($dt).append($ddNote).append($ddLang).append($ddState).append($ddScore);
			$div.append($a).append($dl);
			
			$li = $("<li></li>");
			$li.append($div);
			console.log($li.html());
			$("#notiContent").append($li);
		}
		/*
		var $name = $('<dt><a href='+obj.link+' title='+name+'>' +  obj.name + '</a></dt>');
		var $note = $('<dd>'+obj.note+'</dd>');
		var $lang = $('<dd>语言：'+localStorage["lang"]+'</dd>');
		var $state = $('<dd>'+localStorage["state"]+'</dd>');
		var $score = $('<dd>评分：<font color="red">'+localStorage["score"]+'</font></dd>');
		var $logo = $('<a target="_blank" class="img_a" href="/guochan/xuanyuanjianzhitianzhihen/"><img width="93" height="132" alt="轩辕剑之天之痕" src="http://pica.51rrkan.net/Uploads/vod/2012-07-07/4ff7940a9643d.jpg"></a>');
		var $type = $('<dd>'+obj.type+'</dd>');
		var $updatatime = $('<dd>'+localStorage["updatatime"]+'</dd>');
		
		var $li = $('<li id="' + localStorage["key"] +'"></li>');
		$li.append($name);
		$li.append($note);
		$li.append($lang);
		$li.append($state);
		$li.append($score);
		$li.append($logo);
		$li.append($type);
		$li.append($updatatime);

		
		$("#notiContent").append($li);
		*/
	}		
}